const path = require('path')

function addStyleResource(rule) {
  rule
    .use('style-resource')
    .loader('style-resources-loader')
    .options({
      patterns: [
        path.resolve(__dirname, 'src/styles/variables.scss'),
        path.resolve(__dirname, 'src/styles/mixin.scss')
      ]
    })
}

module.export = {
  // configureWebpack: config => {
  //   if (
  //     process.env.NODE_ENV === "production" &&
  //     process.env.npm_config_report
  //   ) {
  //     return {
  //       plugins: [new BundleAnalyzerPlugin()]
  //     };
  //   }
  // },
  configureWebpack: {
    resolve: {
      alias: {
        assets: '@/assets',
        components: '@/components',
        views: '@/views'
      }
    }
  },
  chainWebpack: config => {
    const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
    types.forEach(type =>
      addStyleResource(config.module.rule('less').oneOf(type))
    )
  }
}
